package com.zmn.plat.services.impl.service.item;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.zmn.plat.model.entity.service.item.ServiceItem;
import com.zmn.plat.model.entity.service.item.ServiceItemQuery;
import com.zmn.plat.model.vo.service.item.ServiceItemVO;
import com.zmn.plat.persistence.interfaces.service.item.ServiceItemDao;
import com.zmn.plat.services.interfaces.service.item.ServiceItemService;

@Service
public class ServiceItemServiceImpl implements ServiceItemService {

    @Resource
    ServiceItemDao faultItemDao;

    @Override
    public ServiceItem findByKey(Integer itemId) {
        return faultItemDao.findByKey(itemId);
    }

    @Override
    public List<ServiceItem> listPageByQuery(ServiceItemQuery query) {
        int count = countByQuery(query);
        query.setTotalCount(count);
        return faultItemDao.listPageByQuery(query);
    }

    @Override
    public List<ServiceItem> listByQuery(ServiceItemQuery query) {
        return faultItemDao.listByQuery(query);
    }

    @Override
    public List<ServiceItem> listAll() {
        return faultItemDao.listAll();
    }

    @Override
    public List<ServiceItem> listByGroupIds(List<Integer> groupIds) {
        return faultItemDao.listByGroupIds(groupIds);
    }

    @Override
    public List<ServiceItem> listByProductId(Integer productId) {
        return faultItemDao.listByProductId(productId);
    }

    @Override
    public List<ServiceItem> listByItemIds(List<Integer> itemIds) {
        return faultItemDao.listByItemIds(itemIds);
    }

    @Override
    public Integer countByQuery(ServiceItemQuery query) {
        return faultItemDao.countByQuery(query);
    }

    @Override
    public Integer updateStatusByKey(ServiceItem faultItem) {
        return faultItemDao.updateStatusByKey(faultItem);
    }

    @Override
    public Integer updateStatusBatchByKey(List<Integer> ids, Integer status, String mcStaffName) {
        return faultItemDao.updateBatchStatusByKey(ids, status, mcStaffName);
    }

    @Override
    public Integer updateSortByKey(ServiceItem faultItem) {
        return faultItemDao.updateSortByKey(faultItem);
    }

    @Override
    public Integer updateSortByKey(Integer itemId, Integer sort, String mcStaffName) {
        ServiceItem faultItem = new ServiceItem();
        faultItem.setItemId(itemId);
        faultItem.setSort(sort);
        faultItem.setUpdater(mcStaffName);

        return updateSortByKey(faultItem);
    }

    @Override
    public Integer updateByKey(ServiceItem faultItem) {
        return faultItemDao.updateByKey(faultItem);
    }

    @Override
    public Integer updateCategNameByCategId(String categName, Integer categId) {
        return faultItemDao.updateCategNameByCategId(categName, categId);
    }

    @Override
    public Integer insert(ServiceItem faultItem) {
        return faultItemDao.insert(faultItem);
    }

    @Override
    public Integer insertBatch(List<ServiceItemVO> itemList) {
        return faultItemDao.insertBatch(itemList);
    }

    @Override
    public Integer deleteByKey(Integer itemId) {
        return faultItemDao.deleteByKey(itemId);
    }

    @Override
    public Integer deleteByGroupIds(List<Integer> groupIds) {
        return faultItemDao.deleteByGroupIds(groupIds);
    }
}